//
//  RHMessageListCell.m
//  RuiHeAppApp
//
//  Created by Jun on 2023/7/21.
//

#import "RHMessageListCell.h"

@interface RHMessageListCell()

@property (nonatomic ,strong) QMUILabel *titleLab;

@property (nonatomic ,strong) QMUILabel *dateLab;

@property (nonatomic ,strong) QMUILabel *desLab;

@property (nonatomic ,strong) QMUIButton *infoBtn;


@end


@implementation RHMessageListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}


- (void)setupUI{
      
    [self setBackgroundColor:UIColor.clearColor];
    [self.contentView setBackgroundColor:UIColor.clearColor];
    
    UIView *bgView = [[UIView alloc] init];
    [bgView setBackgroundColor:UIColor.whiteColor];
    [bgView.layer setCornerRadius:8];
    [self.contentView addSubview:bgView];
    
    _titleLab = [[QMUILabel alloc] init];
    [_titleLab setTextAlignment:NSTextAlignmentLeft];
    [_titleLab setFont:[UIFont boldSystemFontOfSize:16]];
    [_titleLab setTextColor:kCOLOR_HEX(@"3F4443")];
    [bgView addSubview:_titleLab];
    
    _dateLab = [[QMUILabel alloc] init];
    [_dateLab setTextAlignment:NSTextAlignmentLeft];
    [_dateLab setFont:[UIFont systemFontOfSize:12]];
    [_dateLab setTextColor:[kCOLOR_HEX(@"3F4443") colorWithAlphaComponent:0.7]];
    [bgView addSubview:_dateLab];
    
    _desLab = [[QMUILabel alloc] init];
    [_desLab setTextAlignment:NSTextAlignmentLeft];
    [_desLab setFont:[UIFont systemFontOfSize:13]];
    [_desLab setTextColor:[kCOLOR_HEX(@"3F4443") colorWithAlphaComponent:0.7]];
    [_desLab setNumberOfLines:-1];
    [bgView addSubview:_desLab];
    
    
    UIView *lineV = [[UIView alloc] init];
    [lineV setBackgroundColor:CFCellLineColor];
    [bgView addSubview:lineV];
    
    _infoBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
    [_infoBtn setTitle:@"See details" forState:UIControlStateNormal];
    [_infoBtn setTitleColor:[kCOLOR_HEX(@"3F4443") colorWithAlphaComponent:0.7] forState:UIControlStateNormal];
    [_infoBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [_infoBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    [bgView addSubview:_infoBtn];
    
    UIImageView *arrowV = [[UIImageView alloc] init];
    [arrowV setImage:[UIImage imageNamed:@"cell_arrow"]];
    [bgView addSubview:arrowV];
    
    

    kWeakSelf;
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(5, 15, 5, 15));
    }];
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.height.mas_equalTo(20);
    }];
    
    [_dateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.titleLab);
        make.top.equalTo(weakSelf.titleLab.mas_bottom).offset(5);
        make.right.equalTo(weakSelf.titleLab);
        make.height.mas_equalTo(20);
    }];
    
    
    [_desLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.titleLab);
        make.top.equalTo(weakSelf.dateLab.mas_bottom).offset(5);
        make.bottom.equalTo(lineV.mas_top).offset(-5);
        make.height.mas_equalTo(60);
    }];
    
    [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_offset(0);
        make.height.mas_equalTo(1);
        make.bottom.mas_offset(-44);
    }];

    
    [_infoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.titleLab);
        make.size.mas_equalTo(CGSizeMake(120, 30));
        make.top.equalTo(lineV).offset(7);
    }];
    
    [arrowV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.right.mas_offset(-15);
        make.centerY.equalTo(weakSelf.infoBtn);
    }];
    
    
    [_titleLab setText:@"Message Title"];
    [_dateLab setText:@"2023-07-21 18:23"];
    [_desLab setText:@"Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content Message content"];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

@end
